#ifndef EVENTPOLLER_H_
#define EVENTPOLLER_H_

#include <vector>
#include <set>
#include "Singleton.h"
#include "NonCopyable.h"

class EventHandler;

/* Singleton Structure that handles all events stored in the Queue*/
class EventPoller : public NonCopyable
{
private:
    /* Private Default Ctr */
	EventPoller();
    /* So that the Constructor can be called */
	friend class Singleton<EventPoller>;

public:
    /* Polls the event queue and passes it to all event handlers */
	void Update();
    /* stores the handler in the data structure */
	void AddHandler(EventHandler* n);
    /* removes the handler from the data structure */
	void RemoveHandler(EventHandler* n);
    /* purges the EventHandler data structure */
	void ClearHandlers();

private:
    /* Current Implementation uses a Set to assure no handler
     * can recieve the same event twice */
    typedef std::set<EventHandler*> EventHandlerSet;
    EventHandlerSet m_set;
};

/* The name used to access the singleton */
typedef Singleton<EventPoller> TheEventPoller;

#endif